package com.cake.base.config;

/**
 * 优惠券类型
 * @author master
 *
 */
public enum CoupomCategory {
	
	/**
	 * 优惠券类型
	 */
	NEW_MEMBER(1, "新用户优惠券"),
	
	ACTIVITY(2, "促销活动优惠券");
	
	private Integer index;
	
	private String name;
	
    private CoupomCategory(Integer index, String name) {
    	this.index = index;
        this.name = name;
    }

	public Integer getIndex() {
		return index;
	}

	public void setIndex(Integer index) {
		this.index = index;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * 根据枚举的索引，获取名称
	 * 
	 * @param index	枚举索引
	 * @return		返回索引对应的名称(name)
	 */
	public static String getName(Integer index) {
        for (CoupomCategory e : CoupomCategory.values()) {
            if (e.getIndex().equals(index)) {
                return e.name;
            }
        }
        return null;
    }
	
	/**
	 * 根据枚举的名称，获取索引
	 * 
	 * @param name	枚举名称
	 * @return		返回索引对应的索引(index)
	 */
	public static Integer getIndex(String name){
		for (CoupomCategory e : CoupomCategory.values()) {
			if(e.getName().equals(name)){
			}
		}
		return null;
	}
}
